<template>
    <div>
        <Form :model="formItem" inline>
            <FormItem>
                <Input v-model="formItem.company"  placeholder="单位"></Input>
            </FormItem>
            <FormItem>
                <Input v-model="formItem.end_time"  placeholder="休眠时长(天)"></Input>
            </FormItem>
            <FormItem>
                <Button type="success" @click="search">搜索</Button>
            </FormItem>
<!--            <FormItem>-->
<!--                <Button type="primary" @click="see">查看</Button>-->
<!--            </FormItem>-->
            <FormItem>
                <Button type="primary" @click="exportData"><Icon type="ios-download-outline"></Icon>导出</Button>
            </FormItem>
            <FormItem>
                <Button type="info" @click="back()">返回</Button>
            </FormItem>
        </Form>
        <Table border :columns="columns6" :data="data6" ref="table">
        </Table>
    </div>
</template>

<script>
import { getExportSpvOilcompaniesByshuiList } from '@/api/user'
export default {
  data () {
    return {
      total: 0,
      formItem: {
        company: '',
        end_time: '30'
      },
      columns6: [
        {
          title: '单位名称',
          key: 'company',
          align: 'center'
        },
        {
          title: '问题油卡号',
          key: 'card_num_all',
          align: 'center'
        },
        {
          title: '开卡日期',
          key: 'card_time',
          align: 'center',
          width: 150
        },
        {
          title: '卡片状态',
          key: 'card_type',
          align: 'center',
          width: 150
        },
        {
          title: '交易记录',
          key: 'transaction_time',
          align: 'center',
          width: 150
        },
        {
          title: '首次使用日期',
          key: 'min_time',
          align: 'center',
          width: 150
        },
        {
          title: '休眠时长',
          key: 'end_time',
          align: 'center',
          width: 150
        },
        {
          title: '问题类型',
          key: 'problem',
          align: 'center',
          width: 150
        }
        // {
        //   title: '操作',
        //   slot: 'action',
        //   width: 150,
        //   align: 'center'
        // }
        // {
        //   title: '交易时间',
        //   key: 'f'
        // }
      ],
      data6: []
    }
  },
  methods: {
    async init () {
      // console.log('没传', data)
      let xiumian = {
        end_time: this.formItem.end_time
        // end_time: '30'
      }
      getExportSpvOilcompaniesByshuiList(xiumian).then(ret => {
        this.data6 = ret.data.data.results
        this.total = ret.data.data.totalRecord
        this.data6.forEach(item => {
          item.problem = '休眠卡'
        })
      })
    },
    search () {
      const data = {
        company: this.formItem.company,
        end_time: this.formItem.end_time
      }
      getExportSpvOilcompaniesByshuiList(data).then(ret => {
        this.data6 = ret.data.data
      })
      console.log('没传', data)
    },
    // see () {
    //   this.$router.push({
    //     name: 'longXm'
    //   })
    // },
    exportData () {
      for (let i = 0; i < this.data6.length; i++) {
        if (this.data6[i].card_num_all) {
          this.data6[i].card_num_all = '\t' + this.data6[i].card_num_all
        }
      }
      this.$refs.table.exportCsv({
        filename: '导出文件',
        columns: this.columns6,
        data: this.data6
      })
    },
    back () {
      this.$router.push({
        name: 'refueling-seven'
      })
    }
  },

  watch: {

  },

  mounted () {
    this.init()
  }
}

</script>

<style scoped>

</style>
